package com.xqls.util;

import com.xqls.dao.UserMapper;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;

public class Utils {
    private static SqlSessionFactoryBuilder builder;
    private static SqlSessionFactory factory;

    static {
        try {
            builder = new SqlSessionFactoryBuilder();
            InputStream inputStream = Resources.getResourceAsStream("sqlMapConfig.xml");
            factory = builder.build(inputStream);
        }catch (IOException e){
            System.out.println(e.getMessage());
        }
    }


    public static SqlSession getSqlsession(){

        return factory.openSession();
    }
}
